package com.chookss.mine.set

import android.os.Bundle
import android.view.View
import com.chookss.R
import com.lvgroup.hospital.base.BaseAct
import kotlinx.android.synthetic.main.activity_notice_setting.*
import kotlinx.android.synthetic.main.common_title.*

/*通知设置页面*/
class NoticeSettingActivity : BaseAct(), View.OnClickListener {
    private var isGood: Boolean = false
    private var isComment: Boolean = true
    private var isFollow: Boolean = true
    private var isFollowPerSon: Boolean = true

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_notice_setting)
        initState()
    }
    override fun initData() {
        common_title_txt.text="通知设置"
        common_title_back.setOnClickListener(this)
        ivGood.setOnClickListener(this)
        ivComment.setOnClickListener(this)
        ivFollow.setOnClickListener(this)
        ivFollowPerSon.setOnClickListener(this)
    }

    override fun onClick(v: View?) {
        when (v?.id) {
            R.id.common_title_back -> {
                finish()
            }
            R.id.ivGood -> {
                btnSwitch(ivGood, "isGood")
            }
            R.id.ivComment -> {
                btnSwitch(ivComment, "isComment")
            }
            R.id.ivFollow -> {
                btnSwitch(ivFollow, "isFollow")
            }
            R.id.ivFollowPerSon -> {
                btnSwitch(ivFollowPerSon, "isFollowPerSon")
            }
        }
    }
    /*判断每个开关的状态*/
    fun btnSwitch(view: View, isSwitch: String) {
        when (isSwitch) {
            "isGood" -> {
                if (isGood) {
                    ivGood.background = resources.getDrawable(R.mipmap.kaiguan_guan_icon)
                    isGood = false
                } else {
                    ivGood.background = resources.getDrawable(R.mipmap.kaiguan_kai_icon)
                    isGood = true
                }
            }
            "isComment" -> {
                if (isComment) {
                    view.background = resources.getDrawable(R.mipmap.kaiguan_guan_icon)
                    isComment = false
                } else {
                    view.background = resources.getDrawable(R.mipmap.kaiguan_kai_icon)
                    isComment = true
                }
            }
            "isFollow" -> {
                if (isFollow) {
                    view.background = resources.getDrawable(R.mipmap.kaiguan_guan_icon)
                    isFollow = false
                } else {
                    view.background = resources.getDrawable(R.mipmap.kaiguan_kai_icon)
                    isFollow = true
                }
            }
            "isFollowPerSon" -> {
                if (isFollowPerSon) {
                    view.background = resources.getDrawable(R.mipmap.kaiguan_guan_icon)
                    isFollowPerSon = false
                } else {
                    view.background = resources.getDrawable(R.mipmap.kaiguan_kai_icon)
                    isFollowPerSon = true
                }
            }
        }
    }
}